package bytes;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class MarkResetTest {

	public static void main(String[] args) throws IOException {
		
		File file = new File( "src/bytes/MarkResetTest.java" );
		
		InputStream input = new FileInputStream( file );
		
		System.out.println( "mark supported : " + input.markSupported() );
		
		BufferedInputStream bufferedInput = new BufferedInputStream( input );
		
		System.out.println( "mark supported : " + bufferedInput.markSupported() );
		
		System.out.println( "- - - - - - - - - - - - - - - - - - - - - - - -" );
		
		int b ;
		while( ( b = bufferedInput.read() ) != -1 ) {
			char ch = (char) b ;
			if( ch == '@' ) {
				bufferedInput.mark( -250 ); // markpos = pos ;
			} 
			System.out.print( ch );
		}
		
		bufferedInput.reset(); // pos = markpos ;
		
		while( ( b = bufferedInput.read() ) != -1 ) {
			char ch = (char) b ;
			System.out.print( ch );
		}
		
		bufferedInput.close();
		input.close();

	}

}
